import * as houseService from '../services/house';
import router from 'umi/router';

export default {
  namespace: 'house',
  state: {
    ok: true,
    page: {
      current: 1,
      size: 10,
      total: 0,
      records: [],
    }
  },
  reducers: {
    fetchList(state, action) {
      return {
        ...state,
        ok:action.payload.ok,
        page: action.payload.page
      };
    },
  },
  effects: {
    *listPage({payload:{ current=1, size = 10 }}, { call, put }) {
      const res = yield call(houseService.listPage, {current, size });
      const { ok, page } = res.data;
      yield put({
        type: 'fetchList',
        payload: { ok, page }
      });
    }
  }
}
